﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Practices.Unity;
using WpfFeeCalculator.Controllers;
using WpfFeeCalculator.Model;
using WpfFeeCalculator.ViewModel;


namespace WpfFeeCalculator.Locator
{
    public class MainViewModelLocator
    {
        static MainViewModelLocator()
        {
            Container = new UnityContainer();

            Container.RegisterType<IPortfolioController, PortfolioController>();
            Container.RegisterType<IFeeFacade, FeeFacade>();
            Container.RegisterType<IPriceCutOffController, PriceCutOffController>();
            Container.RegisterType<IClientController, ClientController>();
            

            // register as a singleton
            Container.RegisterType<MainWindowViewModel>(new ContainerControlledLifetimeManager());
        }

        public static IUnityContainer Container
        {
            get;
            private set;
        }

        public MainWindowViewModel MainVM
        {
            get
            {
                var vm = Container.Resolve<MainWindowViewModel>();
                return vm;
            }
        }

    }
}
